/**
 * 定义本地测试接口，最好与正式接口一致，尽可能减少联调阶段修改的工作量
 */
// 引入mockjs
import Mock, { Random } from "mockjs";
// 引入模板函数类
import user from "./modules/user.js";
import article from "./modules/article.js";
import archive from "./modules/archive.js";
import category from "./modules/category.js";
import tags from "./modules/tags.js";
import comment from "./modules/comment.js";

const { mock } = Mock; // Mock函数

const baseURL = import.meta.env.VITE_APP_BASE_API;

// 使用拦截规则拦截命中的请求
// mock(url, post/get, 返回的数据/函数（有return值）);
mock(baseURL + "/user/login", "post", user.login);
mock(baseURL + "/user/profile", "post", user.getUserInfo);
mock(baseURL + "/user/logout", "post", user.logout);

// 首页
mock(baseURL + "/article/list", "get", article.articles);
mock(baseURL + "/article/pages", "post", article.articlePages);
mock(baseURL + "/article/hots", "get", article.hotBlogs);
mock(baseURL + "/article/detail", "post", article.blogDetail);

// 归档
mock(baseURL + "/archieve/pages", "post", archive.archievePages);

// 分类
mock(baseURL + "/category/list", "get", category.categoryList);

// 标签
mock(baseURL + "/tag/list", "get", tags.tagList);

// 评论
mock(baseURL + "/comment/pages", "post", comment.commentPages);
mock(baseURL + "/comment/add", "post", comment.addComment);